<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class history extends CI_Controller {

	private $all_session;
	private $id;
	private $data;
	public $input;

	public function __construct()
    {
        parent::__construct();

        @$this->all_session = $this->session->all_userdata();  
        @$this->id = $this->all_session['login'][0]['mem_id'];    
    }

	public function index()
	{				
		$this->data['member'] = $this->main_model->get_member($this->id);

		//////////////////////////////////////////////////////
		//////////////////// pagination //////////////////////
		//////////////////////////////////////////////////////

		$this->load->library('pagination');
		$config['first_tag_open'] = $config['last_tag_open']= $config['next_tag_open']= $config['prev_tag_open'] = $config['num_tag_open'] = '<li>';
        $config['first_tag_close'] = $config['last_tag_close']= $config['next_tag_close']= $config['prev_tag_close'] = $config['num_tag_close'] = '</li>';
        $config['cur_tag_open'] = "<li><span><b>";
        $config['cur_tag_close'] = "</b></span></li>";

		$config['base_url'] = base_url().'index.php/history/index';
		$config['total_rows'] = $this->history_model->count_get_history($this->data['member'][0]['mem_id']);
		$config['per_page'] = 50;
				 
		$per_page = $config['per_page'];
		$uri = $this->uri->segment(3);////////////////////
	
		//////////////////////////////////////////////////////
		/////////////////////// data /////////////////////////
		//////////////////////////////////////////////////////

		$this->data['vdo'] = $this->history_model->get_history($per_page ,$uri ,$this->data['member'][0]['mem_id']);
		$this->pagination->initialize($config); 

		$this->load->view('history' ,$this->data);
	}

	public function delete_history()
	{
		$select_all = $this->input->post('select_all');

		for($i=0;$i<count($select_all);$i++)
		{
			if($select_all[$i] != "")
			{
				$id = $select_all[$i];
				$this->history_model->delete_history($id);
			}
		}

		redirect('history');
	}




}